import service from "@/utils/service"

interface IgetTableArg {
    _page?: number,
    _limit?: number,
    projectid?: string,
    projectname?: string,
    province?: string,
    city?: string,
    suitMechanism?: string

}
// 获取表格数据
// export default async (getTableArg: IgetTableArg) => {
//     let res = await service({
//         url: `/testHospitals`,
//         method: "get",
//         params: getTableArg
//     })
//     if (res.data) {
//         return res.data
//     }
// }
// 获取当前索引条件的总数据量
export const multipleModuleTotal = async (getTableArg: IgetTableArg) => {
    let params: IgetTableArg = {}

    if (getTableArg.projectid) {
        params.projectid = getTableArg.projectid
    }
    if (getTableArg.projectname) {
        params.projectname = getTableArg.projectname
    }

    if (getTableArg.province) {
        if (getTableArg.province !== "全部") {
            params.province = getTableArg.province
        }
    }
    if (getTableArg.city) {
        if (getTableArg.city !== "全部") {
            params.city = getTableArg.city
        }
    }
    if (getTableArg.suitMechanism) {
        params.suitMechanism = getTableArg.suitMechanism
    }
    // 查看params中有几个key
    // Object.keys(params).length
    let res = await service({
        url: `/testHospitals`,
        method: "get",
        params
    })
    if (res.data) {
        return res.data.length
    }
}
// 获取当前索引条件的总数据（分页）
export const multipleModuleData = async (getTableArg: IgetTableArg) => {

    let params: IgetTableArg = {}

    if (getTableArg.projectid) {
        params.projectid = getTableArg.projectid
    }
    if (getTableArg.projectname) {
        params.projectname = getTableArg.projectname
    }
    if (getTableArg.province) {
        if (getTableArg.province !== "全部") {
            params.province = getTableArg.province
        }
    }
    if (getTableArg.city) {
        if (getTableArg.city !== "全部") {
            params.city = getTableArg.city
        }
    }
    if (getTableArg.suitMechanism) {
        params.suitMechanism = getTableArg.suitMechanism
    }
    params._limit = getTableArg._limit
    params._page = getTableArg._page

    let res = await service({
        url: `/testHospitals`,
        method: "get",
        params
    })
    if (res.data) {
        return res.data
    }

}